//
//  NSString+WDLSHA_1.m
//  24-加密
//
//  Created by 王道林 on 16/8/16.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "NSString+WDLSHA_1.h"
#import <CommonCrypto/CommonCrypto.h>
@implementation NSString (WDLSHA_1)

- (NSString *)stringWithSHA_1
{
    const char *cString = [self UTF8String];
    CC_LONG leng = (CC_LONG)strlen(cString);
    unsigned char bytes[CC_SHA1_DIGEST_LENGTH];
    CC_SHA1(cString, leng, bytes);
    NSMutableString *finalSHA1 = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH];
    for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
        [finalSHA1 appendFormat:@"%02x", bytes[i]];
    }
    
    return finalSHA1;
}


@end
